#将某些组件放在一组

import tkinter as tk

def A():
    param = v.get()
    print("选中的值",param)
window = tk.Tk()
window.title('hello thinter')
height= window.winfo_screenheight()
width= window.winfo_screenwidth()
window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))
group = tk.LabelFrame(window, text="请选择",bg='red',fg='blue').pack()
sex = [
    ('男',1),
    ('女',0),
    ('未知',2)
]
v = tk.IntVar()
v.set(2) #设置默认值
for name,value in sex:
     tk.Radiobutton(group, text=name, value=value, variable=v).pack()
tk.Button(group,text="获取选中的值",command=A,bg='red',fg='blue').pack()
window.mainloop()

